18
תגובות
gd התמונה לא עובדת
פתח
itayFO
,
משום מה כל תמונה שאני מנסה ליצור- יוצרת לי ריבוע קטנטן של התמונה לא קיימת.
דוגמא לקוד -
למדתי מהמדריך של האתר ובדקתי וזה מותקן אצלי
דוגמא לקוד -
$img = imagecreatetruecolor(300, 350);
$yellow = imagecolorallocate($img, 255, 255, 0);
imageLine($img, 0, 0, 300, 350, $yellow);
header("Content-type: image/png");
imagepng($img);
$yellow = imagecolorallocate($img, 255, 255, 0);
imageLine($img, 0, 0, 300, 350, $yellow);
header("Content-type: image/png");
imagepng($img);
למדתי מהמדריך של האתר ובדקתי וזה מותקן אצלי
18 תשובות
בדקת שהקוד לא מחזיר שגיאות ?
שים את השורה עם ההדר בהערה ותראה עם אין הודעות על שגיאות.
header
המטרה בלהוריד אותו היית בשביל לגלות הודעות על שגיאות.
אבל אין בקוד שגיאות. אצלי הוא עובד יופי.
אתה פשוט גולש אל הסקריפט שלך ורואה ריבוע קטן ?
גם בדפדפנים אחרים?
זה מראה לך את הקוד המלא של מה ?
מה זה הקוד המלא? את קוד ה PHP?
אתה בטוח שאתה פותח בדפדפן כתובת שמתחילה באותיות http ולא ב file ?
<html>
<head>
</head>
<body>
<?php
$img = imagecreatetruecolor(300, 350);
$yellow = imagecolorallocate($img, 255, 255, 0);
imageLine($img, 0, 0, 300, 350, $yellow);
header("Content-type: image/png");
imagepng($img);
?>
</body>
</html>
פשוט הבאתי רק את הphp בטעות
תעשה קובץ PHP שהקוד בו הוא:
<?php
$img = imagecreatetruecolor(300, 350);
$yellow = imagecolorallocate($img, 255, 255, 0);
imageLine($img, 0, 0, 300, 350, $yellow);
header("Content-type: image/png");
imagepng($img);
?>
$img = imagecreatetruecolor(300, 350);
$yellow = imagecolorallocate($img, 255, 255, 0);
imageLine($img, 0, 0, 300, 350, $yellow);
header("Content-type: image/png");
imagepng($img);
?>
ואז תעשה:
<html>
<head>
</head>
<body>
<ima src="file.php">
</body>
</html>
<head>
</head>
<body>
<ima src="file.php">
</body>
</html>
ניסיתי לכתוב טקסט על תמונה ,
זה מראה לי רק כמה קווים שחורים
<?php
// The text to draw
$text = 'phpguide.co.il';
// Replace path by your own font path
$font = 'arial.ttf';
// Create the image
$im = imagecreatefrompng('logo.png');
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 400, 130, $white);
// Add the text
imagettftext($im, 20, 0, 10, 50, $black, $font, $text);
// Set the content-type
header('Content-type: image/png');
imagepng($im);
// The text to draw
$text = 'phpguide.co.il';
// Replace path by your own font path
$font = 'arial.ttf';
// Create the image
$im = imagecreatefrompng('logo.png');
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 400, 130, $white);
// Add the text
imagettftext($im, 20, 0, 10, 50, $black, $font, $text);
// Set the content-type
header('Content-type: image/png');
imagepng($im);